package com.xiaodeng.edu.mapper;

import com.xiaodeng.edu.pojo.Admin;
import com.xiaodeng.edu.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AdminMapper {
    //管理员注册
    @Insert("insert into admin(admin_user,password,create_time,update_time) values (#{adminUser},#{password},now(),now())")
    void add(@Param("adminUser")String adminUser, @Param("password")String password);

    //查询管理员
    @Select("select * from admin where admin_user = #{adminUser}")
    Admin findByUserName(String adminUser);
    //删除管理员
    @Delete("delete from admin where id = #{id}")
    void delete(Integer id);
    //更新管理员头像
    @Update("update admin set admin_pic=#{avatarUrl},update_time=now() where id =#{id}")
    void updateAvatar(@Param("avatarUrl")String avatarUrl,@Param("id") Integer id);
    //更新管理员信息
    @Update("update admin set nickname=#{nickname},email=#{email},update_time=now() where id=#{id}")
    void update(Admin admin);
    //更新管理员密码
    @Update("update admin set password=#{md5String},update_time=now() where id =#{id}")
    void updatePwd(@Param("md5String") String md5String,@Param("id") Integer id);
    //查询所有用户

    List<User> userlist(String username);
}
